const path = require('path')
const fs = require('fs')

class PublicController {

  upfile(req, res) {
    /* let { originalname, destination, filename } = req.file
    // 得到扩展名 .jpg
    let ext = path.extname(originalname)
    let filepath = path.resolve(path.join(destination, filename))
    fs.renameSync(filepath, filepath + ext)
    res.send({ url: '/uploads/' + filename + ext }) */

    let { filename } = req.file
    res.send({ url: '/uploads/' + filename })
  }

}

module.exports = new PublicController()
